Skip to content

feat(mcp): simplify auth to single /mcp endpoint with optional api_key query param#81

Merged
electather merged 2 commits intomainfrom
feat/simplify-mcp-auth-single-endpoint
Mar 16, 2026
Merged

feat(mcp): simplify auth to single /mcp endpoint with optional api_key query param#81
electather merged 2 commits intomainfrom
feat/simplify-mcp-auth-single-endpoint

Conversation

@electather
Copy link
Owner

@electather electather commented Mar 16, 2026

Summary

Implements #80, extended to also remove --route-token as it is superseded by --allow-api-key-query-param.

Removed:

  • --multi-tenant flag, TenantRoutingHandler, /{token}/mcp path-based routing
  • --route-token flag and path-prefix routing (/abc123/mcp)
  • SafeLogPath (no longer needed without path-based tokens)
  • SEERR_MCP_ROUTE_TOKEN and SEERR_MCP_MULTI_TENANT env vars from all docs

Added:

  • SeerrAPIKeyMiddleware — reads Seerr API key from X-Api-Key header (always on in HTTP mode) or ?api_key= query param (opt-in via --allow-api-key-query-param); header takes precedence; requests with no key return 401
  • SafeLogQuery — redacts api_key=<value> from logged query strings
  • --allow-api-key-query-param / SEERR_MCP_ALLOW_API_KEY_QUERY_PARAM flag

Auth validation updated: HTTP transport now requires --auth-token, --allow-api-key-query-param, or --no-auth.

The MCP endpoint is always /mcp.

Migration from --route-token or --multi-tenant

Clients that used /{token}/mcp or /{seerr-api-token}/mcp should migrate to:

  • Header — send X-Api-Key: <key> on each /mcp request.
  • Query param — enable --allow-api-key-query-param and use /mcp?api_key=<key>.
  • Bearer token — use --auth-token for MCP server access control.

Test plan

  • TestSeerrAPIKeyMiddleware_headerOnly
  • TestSeerrAPIKeyMiddleware_queryParamOnly
  • TestSeerrAPIKeyMiddleware_headerPrecedenceOverQueryParam
  • TestSeerrAPIKeyMiddleware_queryParamDisabled_ignoresQueryParam (returns 401)
  • TestSeerrAPIKeyMiddleware_neitherPresent_returns401
  • TestSeerrAPIKeyMiddleware_queryParam_sensitiveValueNotLogged
  • TestRouteTokenFlagNotRegistered
  • TestMultiTenantFlagNotRegistered
  • TestAllowAPIKeyQueryParamFlagRegistered
  • TestSafeLogQuery (table-driven)
  • TestAPIKeyContextPropagation
  • Full suite passes with -race
  • go vet ./... and go fmt ./... clean

…y query param

Remove the custom multi-tenant path-based routing (--multi-tenant flag,
tenantRoutingHandler, /{token}/mcp paths) and replace it with a simpler
per-request API key mechanism.

Add SeerrAPIKeyMiddleware that reads the Seerr API key from the X-Api-Key
request header (always on) or the api_key query parameter when
--allow-api-key-query-param is enabled. The header takes precedence when
both are present; requests with no key are rejected with 401.

Also simplify SafeLogPath (remove multiTenant parameter) and add
SafeLogQuery to redact api_key values from logged query strings.

Closes #80
Remove --route-token flag and path-based routing entirely. The MCP endpoint
is now always /mcp. All documentation (README, AGENT.md, docker-compose.yml,
schema) updated to replace route-token examples with --allow-api-key-query-param
and remove SEERR_MCP_ROUTE_TOKEN / SEERR_MCP_MULTI_TENANT env var references.

Also remove SafeLogPath (no longer needed without path-based tokens) and
simplify httpLoggingMiddleware signature accordingly. Auth validation now
accepts --allow-api-key-query-param as a valid alternative to --auth-token.
@electather electather merged commit d047d73 into main Mar 16, 2026
2 checks passed
@electather electather deleted the feat/simplify-mcp-auth-single-endpoint branch March 16, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant